package cn.yomigaeri.warn.producer;

import cn.yomigaeri.common.entity.dto.WarnDTO;
import cn.yomigaeri.common.entity.po.Signal;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class WarnProducer {
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    // 单向发送消息
    public void sendSaveMessage(WarnDTO warnDTO) {
        rocketMQTemplate.convertAndSend("warnToSave", warnDTO);
        log.info("发送信号存入数据库的消息成功:{}", warnDTO);
    }

}
